﻿<!doctype html>
<html>
<head>
    <script language="javascript" type="text/javascript">
        var webSocket;
        var _reconnect;
        var uri = "0.0.0.0:0000";
        function init() {
            websocket = new WebSocket("ws://" + uri);
            websocket.onopen = function (evt) {
                clearInterval(_reconnect);
                console.log("CONNECTED");
                var data = {
                    method: 'GetHtml',
                    param: uri
                };
                websocket.send(JSON.stringify(data));
            };
            websocket.onclose = function (evt) {
                console.log("DISCONNECTED");
            };
            websocket.onmessage = function (evt) {
                var data = JSON.parse(evt.data).result;
                document.getElementById('iPage').srcdoc = data;
                websocket.close();
            };
            websocket.onerror = function (evt) {
                console.log('ERROR:' + evt.data);
            };
        }
        function reconnect() {
            _reconnect = setInterval(function () {
                if (websocket.readyState != WebSocket.OPEN) init();
            },
                10000);
        }
    </script>
    <style>
        html, body
        {
            background-color: Blue;
            height: 100%;
            margin: 0px;
            overflow: scroll;
            overflow-y: hidden;
            overflow-x: hidden;
        }
    </style>
</head>
<body onload="init();reconnect();">
<iframe id="iPage" style="width: 100%; height: 100%; border: none;"></iframe>
</body>
</html>
